﻿using LFramework.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace DataServices
{
    public class DaoNewsGroup
    {
        IDBHelper dbhelper = DBFactory.CreateFromConfig("conn");

        public IList<String> LoadAllNewsGroup()
        {
            string sql = "select * from tbNewsGroup";

            DataTable dt = dbhelper.QueryForDataTable(sql);

            IList<String> result = new List<String>();

            foreach (DataRow dr in dt.Rows)
            {
                result.Add(dr["NewsGroup"].ToString());
            }

            return result;
        } 

        public void AddNewsGroup(string newsGroupName)
        {
            string sql = "insert into tbNewsGroup(NewsGroup) values('" + newsGroupName + "')";

            dbhelper.ExecuteSQL_InTrans(sql);
        } 

        public void DeleteNewsGroup(string newsGroupName)
        {
            string sql = "delete from tbNewsGroup where NewsGroup = '" + newsGroupName + "'";

            dbhelper.ExecuteSQL_InTrans(sql);
        }
    }
}
